package com.analyse.stock.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.analyse.stock.mapper.StockDailyRealTimeMapper;
import com.analyse.stock.model.StockDailyRealTimeModel;
import com.analyse.stock.model.StockInfoModel;
import com.analyse.stock.service.IStockDailyRealTime;
import com.analyse.stock.service.IStockInfo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Set;

@Slf4j
@Service
public class StockDailyRealTimeService extends ServiceImpl<StockDailyRealTimeMapper, StockDailyRealTimeModel> implements IStockDailyRealTime {

    @Autowired
    private IStockInfo istockInfo;

    /**
     * 同步日内级别数据
     */
    @Override
    public Integer getRealTime(String stockCodes) {
        Set<String> sets = Sets.newHashSet();
        if(StringUtils.isNotBlank(stockCodes)){
            sets.addAll(Arrays.asList(stockCodes.split(StrUtil.COMMA)));
        }
        List<StockInfoModel> stockList = istockInfo.getStockList(sets);
        if(CollUtil.isEmpty(stockList)){
            return 0;
        }
        return 0;
    }
}
